<template>
	<view>
		<unicloud-db ref="udb" v-slot:default="{data, loading, error, options}" collection="list">
			<view class="list-item" v-for="(item, index) in data" :key="index">
				<text>姓名：{{ item.name }}</text>
				<text>年龄：{{ item.age }}</text>
				<text>性别：{{ item.sex }}</text>
				<button size="mini" @click="handleDelete(item._id)">删除</button>
			</view>
		</unicloud-db>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				
			};
		},
		onShow() {
			this.$refs.udb && this.$refs.udb.refresh()
		},
		methods: {
			async handleDelete(id) {
				await this.$refs.udb.remove(id)
				await this.$refs.udb.refresh()
			}
		}
	}
</script>

<style lang="scss">

</style>
